package cn.akwangl.spring.ioc.dependency.injection;

import cn.akwangl.spring.ioc.repository.UserRepository;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 依赖注入Demo
 *
 * @author youyongkun
 * @date 2021/6/28 16:39
 */
public class DependencyInjectionDemo {

    public static void main(String[] args) {
        String xmlPath = "META-INF/dependency-injection-context.xml";
        ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext(xmlPath);
        beanFactory.refresh();

        // 依赖注入
        UserRepository userRepository = beanFactory.getBean("userRepository", UserRepository.class);
        System.out.println(userRepository);
    }
}
